﻿using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VideoNet.Common
{
    public class PortHelper
    {
        public static void SendCommand(string comPort,byte[] command)
        {
            if (SerialPort.GetPortNames().FirstOrDefault(c => c == comPort) == null) return;
            SerialPort port = new SerialPort(comPort, 9600);
            port.Parity = Parity.None;
            port.DataBits = 8;
            port.StopBits = StopBits.One;
            port.Handshake = Handshake.None;
            port.RtsEnable = true;
            port.ReadTimeout = 2000;
            port.Open();
            port.Write(command, 0, 4);
            port.Close();
        }
    }
}
